// 重要的就是懒标记的处理

#include <iostream>
const int num(1e5 + 10);
using namespace std;
using ll = long long;

ll a[num];
#define lc p << 1
#define rc p << 1 | 1
struct node
{
    int l, r;
    ll sum, add;
} tr[num << 2];
int n, m;
void pushUp(int p) { tr[p].sum = tr[lc].sum + tr[rc].sum; }
void bulid(int p, int l, int r)
{
    tr[p] = {l, r, 0, 0};
    if (l == r)
    {
        tr[p].sum = a[r];
        return;
    }
    int mid((r + l) >> 1);
    bulid(lc, l, mid);
    bulid(rc, mid + 1, r);
    pushUp(p);
}
void lazy(int p, ll k)
{
    tr[p].sum += (tr[p].r - tr[p].l + 1) * k;
    tr[p].add += k;
}
void pushDown(int p)
{
    lazy(lc, tr[p].add);
    lazy(rc, tr[p].add);
    tr[p].add = 0;
}
void modify(int p, int x, int y, ll k)
{
    int l = tr[p].l, r = tr[p].r;
    if (x <= l && r <= y)
    {
        lazy(p, k);
        return;
    }

    int mid = (l + r) >> 1;
    pushDown(p);
    if (x <= mid)
        modify(lc, x, y, k);
    if (y > mid)
        modify(rc, x, y, k);
    pushUp(p);
}
ll query(int p, int x, int y)
{
    int l = tr[p].l, r = tr[p].r;
    if (x <= l && y >= r)
        return tr[p].sum;

    int mid = (l + r) >> 1;
    ll sum = 0;
    pushDown(p);
    if (x <= mid)
        sum += query(lc, x, y);
    if (y > mid)
        sum += query(rc, x, y);

    return sum;
}

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    bulid(1, 1, n);
    while (m--)
    {
        int op, x, y;
        cin >> op >> x >> y;
        ll k;
        if (op == 1)
        {
            cin >> k;
            modify(1, x, y, k);
        }
        else
            cout << query(1, x, y) << endl;
    }

    return 0;
}